/* 
 * File:   JServerWorkerSVN.cpp
 * Author: johnneyshi
 * 
 * Created on 2013年5月18日, 下午3:03
 */

#include "JServerWorkerSVN.h"
#include "JClient.h"
#include "JFile.h"
#include "JRepositoryConfig.h"
#include "JSVNSock_Stream_InterConversion.h"
#include "JWorkerThreadSVN.h"
#include <iostream>
#include <pthread.h>

using namespace std;

JServerWorkerSVN::JServerWorkerSVN() 
{
}

JServerWorkerSVN::~JServerWorkerSVN() 
{
}

//void JServerWorkerSVN::DealEpollFd(int fd)
//{
//    cout << "Deal Epoll fd" << fd << endl;
//    //读取描述符中的内容到文件
//    JSVNSock_Stream_InterConversion::SockToStream(fd,JRepositoryConfig::repositoryInTempStreamFileName);
//    serverStub.AnalysisCommand();
//}

void* SVNThreadMain(void* arg)
{
    JServerWorker* pWorker = (JServerWorker*)arg;
    //JWorkerThread thread(pWorker,true);
    JWorkerThreadSVN thread(pWorker,true);
    thread.Start();
}

void JServerWorkerSVN::MakeThreads(int _threadCount)
{
    pthread_t pid;
    for(int i = 0;i < _threadCount; ++i)
    {
        this->point1 = &(this->serverStub);
        pthread_create(&pid,NULL,&SVNThreadMain,(void*)this);
        //JLog::Log(JLogMessage,"Create thread %u\n",pid);
    }
}